import junit.framework.TestCase;
import org.junit.Test;
import java.util.Arrays;

public class ArrStrtest extends TestCase {
    @Test
    public void teststr(){
        String string=new String();
        String[] str=new String[10];
        string="i love java which is fucking awesome";
        char[] at=new char[36];
        for(int i=0;i<36;i++)
        {
            at[i]=string.charAt(i);
        }//
        assertEquals(' ',at[1]);//正常
        assertEquals('f',at[21]);//正常
        assertEquals('i',at[0]);//边界
        assertEquals('e',at[35]);//边界
        //assertEquals('i',at[12]);//异常
        //assertEquals('e',at[36]);//异常
        str=string.split(" ");
        assertEquals("love",str[1]);//正常
        assertEquals("fucking",str[5]);//正常
        assertEquals("i",str[0]);//边界
        assertEquals("awesome",str[6]);//边界
        //assertEquals(" which",str[3]);//异常
        //assertEquals("i",str[7]);//异常
    }
    @Test
    public void testarr()
    {
        int[] arr={2,0,7,5,3,1,9};
        int m,n;
        Arrays.sort(arr);
        assertEquals(1,arr[1]);//正常
        assertEquals(5,arr[4]);//正常
        assertEquals(0,arr[0]);//边界
        assertEquals(9,arr[6]);//边界
        //assertEquals(0,arr[5]);//异常
        //assertEquals(6,arr[8]);//异常
        m=Arrays.binarySearch(arr, 5);
        n=Arrays.binarySearch(arr, 4);
        assertEquals(4,m);//找到关键字
        assertEquals(-5,n);//未找到关键字

    }
}